package com.zhuge_new.Adapter;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.PluralsRes;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.util.MultiTypeDelegate;
import com.zhuge_new.R;
import com.zhuge_new.bean.AllplanBean;
import com.zhuge_new.untils.Tailuntils;

import java.util.Calendar;
import java.util.List;

/**
 * Created by lenovo on 2018-09-26.
 */

public class AllplasnAdapter extends BaseQuickAdapter<AllplanBean.RepaymentsBean,BaseViewHolder>{



    private Context context;
    private AllplanBean allplanBean;
    private int positon;
    private String month;

    public AllplasnAdapter(Context context, AllplanBean allplanBean) {
        super(R.layout.item_allplan1, allplanBean.getRepayments());
        this.context=context;
        this.allplanBean=allplanBean;
    }

    @Override
    protected void convert(BaseViewHolder helper, AllplanBean.RepaymentsBean item) {
        helper.setText(R.id.all_pattern,item.getRepaymentType());
        if (item.getCardNo().length()==0){
            return;
        }else {
            String card= Tailuntils.getCardTailNum(item.getCardNo());
            helper.setText(R.id.all_tail,"信用卡还款 尾号("+card+")");
        }

        helper.setText(R.id.all_money,item.getRepaymentSum());
        TextView all_month=helper.getView(R.id.all_month);
        Calendar calendar = Calendar.getInstance();
        int current = calendar.get(Calendar.MONTH) + 1;
        if (current<10){
            month = "0"+String.valueOf(current);
        }else {
            month= String.valueOf(current);
        }
        String time = item.getCreateDate().substring(5, 7);
        switch (time){
            case "01":
                all_month.setText("一月份计划");
                break;
            case "02":
                all_month.setText("二月份计划");
                break;
            case "03":
                all_month.setText("三月份计划");
                break;
            case "04":
                all_month.setText("四月份计划");
                break;
            case "05":
                all_month.setText("五月份计划");
                break;
            case "06":
                all_month.setText("六月份计划");
                break;
            case "07":
                all_month.setText("七月份计划");
                break;
            case "08":
                all_month.setText("八月份计划");
                break;
            case "09":
                all_month.setText("九月份计划");
                break;
            case "10":
                all_month.setText("十月份计划");
                break;
            case "11":
                all_month.setText("十一月份计划");
                break;
            case "12":
                all_month.setText("十二月份计划");
                break;
        }
        helper.addOnClickListener(R.id.all_particulars);
        helper.addOnClickListener(R.id.all_delete);
    }
}
